﻿using System.Windows.Forms;
using GeoSketch2.Core;

namespace GeoSketch2.Archaeo
{
    /// <summary>
    /// The tool to draw Point2D objects
    /// </summary>
    public class TPoint2D : BaseArchaeoTool
    {
        #region Constructor
        /// <summary>
        /// The tool to draw AcheoPoint2D objects
        /// </summary>
        /// <param name="Viewport">The viewport to draw to</param>
        public TPoint2D(Viewport Viewport)
            : base(Viewport,"Point 2D")
        {
        } 
        #endregion

        #region Inputs
        /// <summary>
        /// The method called when the mouse button is down
        /// </summary>
        public override void MouseDown(MouseEventArgs MouseArgs)
        {
            ExternalPointSent(Viewport.Object2ImageTransformation.InverseTransform(MouseArgs.Location));
        }

        /// <summary>
        /// The method called when a text is sent to the tool
        /// </summary>
        public override void TextEntry(string Text)
        {
            ExternalPointSent(GetCoordinatesFromString(Text));
        }

        /// <summary>
        /// The method called when a point in object coordinates is sent to the tool
        /// </summary>
        public override void ExternalPointSent(Point2D64D Point)
        {
            Point2D NewPoint = new Point2D(
                Point,
                Viewport.CurrentLayer,
                Viewport.CurrentExcavationArea,
                Viewport.CurrentColor,
                Viewport.CurrentLineType);
            Viewport.GeoObjects.Add(NewPoint);
            NewPoint.Draw(Viewport);
        }
        #endregion

        #region Methods
        /// <summary>
        /// The method to be used to send the first message to the user, just after beeing selected
        /// </summary>
        public override void SendFirstMessage()
        {
            SendMessage("Click or enter coordinates");
        } 
        #endregion
    }
}
